<template>
  <div>
    <div class="top">爆爆团</div>
    <div class="banner">限时爆款 超级低价</div>
    <div class="news">
      <div
        v-for="(item, index) in changelist"
        :key="index"
        :class="{ check: pindex == index }" @click="changeOne(index)"
      >
        {{ item.name }}
      </div>
    </div>
    <div class="food">
      <div class="foodlist" v-for="(item, index) in foodlist" :key="index">
        <div class="img-box">
          <img :src="item.picture" alt="" />
        </div>
        <div class="trano">
          <div class="name">{{ item.name }}</div>
          <div class="tuan">爆爆团价</div>
          <div class="min_price">
            ￥{{ item.min_price }}
            <span class="zhe">{{ item.promotion_info }}</span>
            <span class="qianggou">马上抢</span>
          </div>
          <div class="month">
            <span class="del"><del>￥31.2</del> </span>
            <span>{{ item.month_saled_content }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { onMounted, ref } from "vue";
import { tuan_list } from "../../api/index";
var foodlist = ref([]);
var pindex = 0;
var changelist = ref([
  { id: 1, name: "正在抢购" },
  { id: 2, name: "上新预告" },
]);
var changeOne = (index) => {
  pindex = index;
  if (index == 1) {
    tuan_list({ status: 1 }).then((res) => {
      foodlist.value = res.data.list;
    });
  } else {
    tuan_list({ status: 0 }).then((res) => {
      foodlist.value = res.data.list;
    });
  }
};
onMounted(() => {
  tuan_list({ status: 0 }).then((res) => {
    foodlist.value = res.data.list;
    console.log(res.data.list);
  });
});
</script>
<style scoped>
.top {
  width: 100%;
  background-color: #ff0000;
  text-align: center;
  line-height: 60px;
  font-weight: 700;
  color: #fff;
  font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
  font-size: 30px;
}
.banner {
  width: 100%;
  height: 100px;
  color: #fce8c3;
  text-align: center;
  line-height: 100px;
  font-size: 40px;
  background: linear-gradient(to bottom, #fd0000, #fe8600);
}
.news {
  width: 100%;
  height: 60px;
  background: linear-gradient(to bottom, #fe4400, #fea900);
  display: flex;
  color: #fff;
  align-items: center;
}
.news div {
  margin-right: 20px;
}
.check{
    color: #fff;
    font-weight: 700;
    font-size: 25px;
}
.food .foodlist img {
  width: 100px;
  height: 100px;
  margin-right: 5px;
}
.food {
  flex: 1;
}
.foodlist {
  display: flex;
  height: 100px;
  margin-bottom: 20px;
  box-sizing: border-box;
  background-color: #fefefe;
}
.trano {
  flex: 1;
  font-size: 12px;
}
.zhe {
  font-size: 12px;
  height: 20px;
  color: orangered;
  line-height: 20px;
  border-radius: 10px;
}
.trano .name {
  font-weight: 700;
  font-size: 20px;
}
.tuan {
  color: orangered;
}
.min_price {
  font-size: 20px;
  color: orangered;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}
.food .foodlist .trano .qianggou {
  display: inline-block;
  width: 60px;
  color: #fff;
  font-size: 16px;
  height: 30px;
  border-radius: 20px;
  text-align: center;
  line-height: 30px;
  margin-left: 20px;
  background-color: red;
}
.del {
  color: grey;
}
.month {
  display: flex;
  justify-content: space-between;
}
.month span:nth-child(2) {
  color: orangered;
}
</style>